﻿using Nop.Core.Domain.Logistics;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nop.Data.Mapping.Logistics
{
    public class PlanMap : EntityTypeConfiguration<LogisticsPlan>
    {
        public PlanMap()
        {
            this.ToTable("LogisticsPlan");

            this.Property(p => p.Status).IsRequired();
            
            this.HasOptional(p => p.Courier)
                .WithMany()
                .HasForeignKey(p => p.CourierId)
                .WillCascadeOnDelete(false);

            this.HasOptional(p => p.Warehouse)
                .WithMany()
                .HasForeignKey(p => p.WarehouseId)
                .WillCascadeOnDelete(false);
            this.HasOptional(p => p.District)
                .WithMany()
                .HasForeignKey(p => p.DistrictId)
                .WillCascadeOnDelete(false);

            this.HasOptional(p => p.Customer)
                .WithMany()
                .HasForeignKey(p => p.CustomerId)
                .WillCascadeOnDelete(false);
        }
    }
}
